%% Run Lib-linear on title and help data

% Entire dataset
B = 0.1;
[results, info, yhat] = lin_liblinear(XcvTrain, YcvTrain, ...
   XcvTest, YcvTest, 7, B);

% title and help dataset
[results_th, info_th, yhat_th] = lin_liblinear(XcvTrainHelpTitle, YcvTrain, ...
   XcvTestHelpTitle, YcvTest, 7);

% Used to calculate expected value
ratings = [2 1 5 4];

% Calc expected value and RMSE for entire CV dataset
[rmse, rmseE, yhatE] = calc_rmse (info.vals, ratings, YcvTest, yhat);

% Calc expected value and RMSE for title and help dataset
[rmse_th, rmseE_th, yhatE_th] = calc_rmse (info_th.vals, ratings, YcvTest, yhat_th);

% Combine two yhat and yhat_E 
combined_yhat = (yhat_th + yhat)./2;
combined_yhatE = (yhatE_th + yhatE)./2;

% Calc expected value and RMSE combined yhat and yhatE
n = numel (YcvTest);

rmse_comb = sqrt (sum ((YcvTest - combined_yhat) .^ 2) / n);
rmseE_comb = sqrt (sum ((YcvTest - combined_yhatE) .^ 2) / n);

% Display results
disp (sprintf ('RMSE %g, RMSE for expected values %g\n', ...
  rmse_comb, rmseE_comb));
